Count Generic Method

Wintellect PowerCollections

Collapse imageExpand ImageCollapseAll imageExpandAll imageDropDown imageDropDownHover imageCopy imageCopyHover image
[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Count the number of items in an IEnumerable<T> collection. If a more specific collection type is being used, it is more efficient to use the Count property, if one is provided.

Namespace: Wintellect.PowerCollections
Assembly:  PowerCollections (in PowerCollections.dll)

Syntax

C#
public static int Count<T>(
	IEnumerable<T> collection
)
Visual Basic (Declaration)
Public Shared Function Count(Of T) ( _
	collection As IEnumerable(Of T) _
) As Integer
Visual C++
public:
generic<typename T>
static int Count (
	IEnumerable<T>^ collection
)

Parameters

collection
IEnumerable<(Of <T>)>
The collection to count items in.

Return Value

The number of items in the collection.

Type Parameters

T

Remarks

If the collection implements ICollection<T>, this method simply returns ICollection<T>.Count. Otherwise, it enumerates all items and counts them.

Exceptions

ExceptionCondition
System..::ArgumentNullExceptioncollection is null.

See Also